<template>
	<view style="height: 100vh;position: relative;background-color: #FFFFFF;" v-if="recipeDetail">
		<view style="padding-left: 40rpx;background-color: #FFFFFF;">
			<view style="font-size: 35rpx;font-weight: bold;margin-top: 30rpx;margin-bottom: 30rpx;">
				<text>NO:</text>
				<text>{{recipeDetail.recipeCode}}</text>
			</view>
			<view class="my-yao">
				<view>
					<text style="margin-right: 20rpx;font-weight: bolder;color: #000000;">就诊人:</text>
					<text style="margin-right: 20rpx">{{recipeDetail.treatName}}</text>
					<text style="margin-right: 20rpx">{{recipeDetail.treatSex}}</text>
					<text>{{recipeDetail.treatAge}}</text>
				</view>
			</view>
			<view style="font-size: 35rpx;font-weight: bold;margin-top: 30rpx;margin-bottom: 30rpx;">
				<text>患者症状描述</text>
			</view>
			<view class="my-yao">
				<view>
					{{recipeDetail.problem?recipeDetail.problem:'无'}}
				</view>
			</view>
			<view class="my-yao">
				<view>
					<text style="margin-right: 20rpx;font-weight: bolder;color: #000000;">科室:</text>
					<text>{{recipeDetail.deptName}}</text>
				</view>
			</view>
			<view class="my-yao">
				<view>
					<text style="margin-right: 20rpx;font-weight: bolder;color: #000000;">日期:</text>
					<text>{{recipeDetail.auditDate}}</text>
				</view>
			</view>
		</view>
		<view style="padding-left: 40rpx;background-color: #FFFFFF;padding-bottom: 20rpx;border-top: 2rpx solid #eaeaea;padding-top: 20rpx;">
			<view style="font-size: 35rpx;font-weight: bold;">诊断:</view>
			<view class="my-yao">
				<view>
					<text v-for="item in recipeDetail.diseaInfo" :key="item.diseDiseaseId">
						{{item.name}}
					</text>
				</view>
			</view>
			<view style="font-size: 35rpx;font-weight: bold;">遗嘱:</view>
			<view class="my-yao">
				<view>
					{{recipeDetail.entrustDoc}}
				</view>
			</view>
		</view>
		<view style="background-color: #FFFFFF;border-top: 2rpx solid #eaeaea;padding-top: 20rpx;padding-bottom: 20rpx;">
			<view class="pl20 pr20 mt20 ft17 c74a6fd bold">Rp:</view>
			<view class="flex flex-ac flex-pj pt10 pb10" style="justify-content: flex-start;padding-left: 20rpx;">
				<text class="cfec322">药品总计:</text>
				<text class="cfec322" style="margin-left: 10rpx;">￥{{recipeDetail.totalFee}}</text>
			</view>
		</view>
		<view style="background-color: #FFFFFF;border-top: 2rpx solid #eaeaea;padding-top: 20rpx;padding-bottom: 20rpx;">
			<view class="flex flex-ac flex-pj pt10 pb10" style="padding-left: 20rpx;">
				<view>
					<text>药房:</text>
					<text style="margin-left: 10rpx;">{{recipeDetail.offcinaPostion.name}}</text>
				</view> 
			</view>
			<view class="flex flex-ac flex-pj pt10 pb10" style="padding-left: 20rpx;padding-right: 20rpx;">
				<view>
					<text>地址:</text>
					<text style="margin-left: 10rpx;">{{recipeDetail.offcinaPostion.address}}</text>
				</view> 
				<text style="color: #007AFF;">导航到店</text>
			</view>
		</view>
		<view style="background-color: #FFFFFF;border-top: 2rpx solid #eaeaea;padding-top: 20rpx;padding-bottom: 20rpx;">
			<view class="flex flex-ac flex-pj pt10 pb10" style="padding-left: 20rpx;padding-right: 20rpx;">
				<view>
					<text>医师:</text>
					<text style="margin-left: 10rpx;">{{recipeDetail.doctorName}}</text>
				</view> 
				<view>
					<text>药师:</text>
					<text style="margin-left: 10rpx;">{{recipeDetail.auditName}}</text>
				</view> 
			</view>
			<view class="flex flex-ac flex-pj pt10 pb10" style="padding-left: 20rpx;">
				<view>
					<text>开具日期:</text>
					<text style="margin-left: 10rpx;">{{formatDate(recipeDetail.auditDate)}}</text>
				</view> 
			</view>
		</view>
		<view style="width: 100%;">
			<view class="add-btn" @click="payMonty">待支付</view>
		</view>
		
		<uni-popup ref="popup" type="message">
		    <uni-popup-message :type="warnType" :message='warnMessage' :duration="warnTime"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	const WxAuth =  require('@/utils/wxlogin');
	export default {
		data() {
			return {
				wx: "https://app.mzmzb.com",
				recipeDetail: undefined,
				recipeId:'',
				totalFee: 0,
				usrUserId:undefined,
				buyMode:1,
				warnMessage:'错误',//消息内容
				warnType:'warn',//消息类型  success/warn/info/error
				warnTime:1000,//消息提醒延长时间
				payState:null, //支付状态 (0-未支付 1-已支付 2-已派药 3-待退款)
				addressId:''//收货地址id
			};
		},
		onLoad(options) {
			this.recipeId = options.recipeId
			this.usrUserId = options.usrUserId
			this.getDrugListByRecipeId();
		},
		methods: {
			getDrugListByRecipeId(){
				this.func.$request('recipe/detail.tz',{recipeId: this.recipeId},'GET').then(res=>{
					if (res.data.success = true) {
						this.recipeDetail = res.data.result
						if(typeof res.data.result.buyMode!='undefined'){
							this.buyMode = res.data.result.buyMode;
						}
						if(res.data.result.totalFee){
							this.totalFee = res.data.result.totalFee;
						}
						if(typeof res.data.result.payState !='undefined'){
							this.payState = res.data.result.payState;
						}
						if(res.data.result.addressId){
							this.addressId = res.data.result.addressId;
						}
					}
				})
			},
			formatDate(value) {
			  var date = new Date(value);
			  var y = date.getFullYear(),
			    m = date.getMonth() + 1,
			    d = date.getDate(),
			    h = date.getHours(),
			    i = date.getMinutes(),
			    s = date.getSeconds();
			  if (m < 10) { m = '0' + m; }
			  if (d < 10) { d = '0' + d; }
			  if (h < 10) { h = '0' + h; }
			  if (i < 10) { i = '0' + i; }
			  if (s < 10) { s = '0' + s; }
			  var t = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
			  return t;
			},
			payMonty(){
				//获取code
				// WxAuth.onLogin().then(code => {});
			}
		}
	};
</script>

<style lang="less">
	.my-yao{
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: calc(100% - 40rpx );
		margin-bottom: 20rpx;
		color: #999999;
	}
	.drug-row{
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: calc( 100% - 40rpx );
		margin-top: 20rpx;
	}
	.add-btn{
		margin: auto;
		height: 88rpx;
		line-height: 88rpx;
		width: 90%;
		background: #BE965B;
		border-radius: 44rpx;
		color: #FFFFFF;
		text-align: center;
	}
</style>
